package com.tedu.egweibo3.base.interceptor;

import com.tedu.egweibo3.base.response.JsonResult;
import com.tedu.egweibo3.base.response.StatusCode;
import com.tedu.egweibo3.pojo.vo.UserVO;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpSession;
import org.springframework.web.servlet.HandlerInterceptor;

public class LoginInterceptor implements HandlerInterceptor {
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        HttpSession session = request.getSession();
        UserVO userVO = (UserVO) session.getAttribute("user");
        if (userVO == null) {
            throw new NullPointerException("未登录");
        }
        return true;
    }
}
